package rdp;

import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class CMPMain implements TabCompleter {
    private String[] rdp = {"help", "menu", "achieve", "base", "market", "occupy", "skill", "team","vocation"};
    private String[] achivement = {"help", "menu"};
    private String[] base = {"help", "menu", "time", "position", "enderchest", "inventory"};
    private String[] market = {"help", "menu"};
    private String[] occupy = {"help", "menu"};
    private String[] skill = {"help", "menu"};
    private String[] team = {"help", "menu", "join", "leave", "invite", "kick", "list"};

    @Override
    public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
        if (args.length > 2)
            return new ArrayList<>();
        if (args.length == 1)
            return Arrays.asList(rdp);
        if (args.length == 2 || args[0].equals("base"))
            return Arrays.asList(achivement);
        if (args.length == 2 || args[0].equals("achieve"))
            return Arrays.asList(base);
        if (args.length == 2 || args[0].equals("market"))
            return Arrays.asList(team);
        if (args.length == 2 || args[0].equals("occupy"))
            return Arrays.asList(team);
        if (args.length == 2 || args[0].equals("skill"))
            return Arrays.asList(team);
        if (args.length == 2 || args[0].equals("team"))
            return Arrays.asList(team);
        return Arrays.stream(rdp).filter(s -> s.startsWith(args[0])).collect(Collectors.toList());
    }
}
